Skip to content

CSR: preserve trap values when interrupts win - #298

Open
good-circle wants to merge 1 commit into
masterfrom
good-circle-1125
Open

good-circle wants to merge 1 commit into
masterfrom
good-circle-1125

Conversation

@good-circle

Copy link
Copy Markdown
Collaborator

If an interrupt and a page fault or misaligned access are pending together, trap cause, delegation, and target selection already prioritize the interrupt. The independent exception paths can still write a trap-value CSR, however. For example, an interrupt targeting M-mode can leave stval overwritten by a page fault that would have been delegated to S-mode, even though no S-mode trap was taken.

Gate page-fault and misaligned-access trap-value writes with !raiseIntr so they follow the existing trap-selection priority.

Validation: 30 directed CSR RTL cases passed after the fix; the original RTL failed 10. The corrected S2C bit also passed a 12-billion-instruction mcf prefix with FORK DiffTest at 50 MHz and 16 GiB RAM.

An interrupt can win trap selection while a pending page fault or
misaligned access still writes its trap-value CSR. When the interrupt
targets M-mode and the exception is delegated to S-mode, this corrupts
stval even though no S-mode trap is taken.

Gate those exception writes with !raiseIntr so they follow the same
priority as cause, delegation and trap-target selection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant